package com.tjec.project.projectWorkbench.controller;

import java.util.List;

import com.tjec.framework.interceptor.annotation.RepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.projectWorkbench.domain.BmsProjectStakeholder;
import com.tjec.project.projectWorkbench.service.IBmsProjectStakeholderService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 项目干系人Controller
 *
 * @author cjj
 * @date 2020-04-26
 */
@Api(value = "项目主页-项目干系人" , tags = {"项目主页-项目干系人接口"})
@RestController
@RequestMapping("/project/stakeholder")
public class BmsProjectStakeholderController extends BaseController
{
    @Autowired
    private IBmsProjectStakeholderService bmsProjectStakeholderService;

    /**
     * 查询项目干系人列表
     */
    @ApiOperation("查询项目干系人列表")
//    @PreAuthorize("@ss.hasPermi('project:stakeholder:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsProjectStakeholder bmsProjectStakeholder)
    {
        startPage();
        List<BmsProjectStakeholder> list = bmsProjectStakeholderService.selectBmsProjectStakeholderList(bmsProjectStakeholder);
        return getDataTable(list);
    }

    /**
     * 获取项目干系人详细信息
     */
    @ApiOperation("获取项目干系人详细信息")
    @ApiImplicitParam(name = "guid", value = "项目干系人guid", required = true, dataType = "String", paramType = "path")
//    @PreAuthorize("@ss.hasPermi('project:stakeholder:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(bmsProjectStakeholderService.selectBmsProjectStakeholderByGuid(guid));
    }

    /**
     * 新增项目干系人
     */
    @ApiOperation("新增项目干系人")
    @ApiImplicitParam(name = "bmsProjectStakeholder", value = "新增项目干系人", dataType = "BmsProjectStakeholder")
    @Log(title = "项目干系人", businessType = BusinessType.INSERT)
//    @PreAuthorize("@ss.hasPermi('project:stakeholder:add')")
    @RepeatSubmit
    @PostMapping
    public AjaxResult add(@RequestBody BmsProjectStakeholder bmsProjectStakeholder)
    {
        return toAjax(bmsProjectStakeholderService.insertBmsProjectStakeholder(bmsProjectStakeholder));
    }

    /**
     * 修改项目干系人
     */
    @ApiOperation("修改项目干系人")
    @ApiImplicitParam(name = "bmsProjectStakeholder", value = "修改项目干系人", dataType = "BmsProjectStakeholder")
    @Log(title = "项目干系人", businessType = BusinessType.UPDATE)
//    @PreAuthorize("@ss.hasPermi('project:stakeholder:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody BmsProjectStakeholder bmsProjectStakeholder)
    {
        return toAjax(bmsProjectStakeholderService.updateBmsProjectStakeholder(bmsProjectStakeholder));
    }

    /**
     * 删除项目干系人
     */
    @ApiOperation("删除项目干系人")
    @ApiImplicitParam(name = "guids", value = "项目干系人guid集合", required = true, dataType = "Array", paramType = "path")
    @Log(title = "项目干系人", businessType = BusinessType.DELETE)
//    @PreAuthorize("@ss.hasPermi('project:stakeholder:remove')")
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(bmsProjectStakeholderService.deleteBmsProjectStakeholderByGuids(guids));
    }
}
